{# vim: set et ts=8 sts=4 sw=4 ai: #}
{% if pagepath %}
{% extends "page.html" %}
{% else %}
{% extends "wiki.html" %}
{% endif %}

{%block head -%}
{{- super() }}
{%- if not revision %}
    <meta name="robots" content="noindex, nofollow"/>
{%- endif %}
{% endblock head -%}

{% block menu %}
{{ super() }}
{% if not pagepath and menutree %}
{% include 'snippets/menutree.html' %}
{% endif %}
{% endblock %}

{% block content %}
<div class="w-full mw-full p-0 clearfix">
{% if rev_a and rev_b %}
    <h3>Comparing <tt>{{rev_a}}</tt> to <tt>{{rev_b}}</tt></h3>
{% elif revision %}
    <h3>Commit <tt>{{revision}}</tt></h3>
{% endif %}
{% if metadata %}
<span class="datetime" title="{{metadata.datetime|format_datetime("deltanow")}} ago">{{metadata.datetime|format_datetime}}</span>
{%if not metadata.author_email%}{{metadata.author_name}}{%else%}<a href="mailto:{{metadata.author_email}}">{{metadata.author_name}}</a>{%endif%}:
{{metadata.message or '-/-'|safe}}
{%endif%}
<table class="diff">
{% for file in patchset %}
{% with filename=file.path,lines=file_diffs[file.path],urlobj=url_map[file.path] %}
{# {{filename}} {{lines}} {{file}} #}
{%- if page_filename|length == 0 or filename == page_filename %}
<tr>
<td class="filename" colspan="{%if withlinenumbers %}4{%else%}2{%endif%}">
{%- if urlobj.source_file == urlobj.target_file %}
    <tt>{{urlobj.source_file}}</tt> <a href="{{urlobj.source_url}}" class="revision-small">{{rev_a}}</a> ..
    <a href="{{urlobj.target_url}}" class="revision-small">{{rev_b}}</a>
{%- else %}
    {%- if urlobj.source_url %}
    <a href="{{urlobj.source_url}}"><tt>{{urlobj.source_file}}</tt></a>
    {%- else %}
    <tt>{{urlobj.source_file}}</tt>
    {%- endif %}
    ..
    {%- if urlobj.target_url %}
    <a href="{{urlobj.target_url}}"><tt>{{urlobj.target_file}}</tt></a>
    {%- else %}
    <tt>{{urlobj.target_file}}</tt>
    {%- endif %}
{%- endif %}
{#
{%- elif rev_a and rev_b %}
    <tt>{{url_map[filename][0][0]}}</tt> <a href="{{url_map[filename][0][1]}}" class="revision-small">{{rev_a}}</a> .. <a href="{{url_map[filename][1][1]}}" class="revision-small">{{rev_b}}</a>
    {%- endif %}
#}
</td>
</tr>
{% for l in lines %}
<tr class="{{l.style}}">
{%- if l.style == "hunk" %}
<td class="hunk" colspan="{%if withlinenumbers %}4{%else%}2{%endif%}">{{l.value}}</td>
{%- else %}
{%-if withlinenumbers -%}
    <td class="diff-decoration">{{l.source}}</td>
    <td class="diff-decoration">{{l.target}}</td>
{%- endif -%}
    <td class="diff-decoration">{{l.type}}</td>
    <td class="value">{{l.value | replace('\n', '')}}</td>
{%- endif -%}
</tr>
{%- endfor -%}{# l in lines #}
{%- else -%}
<!-- skipped page_filename={{page_filename}} filename={{filename}} -->
{%- endif %}
{% endwith %}{# filename,lines in file_diffs #}
{% endfor %}{# filename,lines in file_diffs #}
</table>
{######}
{% endblock %}
